package cn.wusifx.zabbix.request.builder.configuration;

import cn.wusifx.zabbix.request.BaseRequest;
import cn.wusifx.zabbix.request.builder.RequestBuilder;

import java.util.HashMap;
import java.util.Map;

/**
 * https://www.zabbix.com/documentation/4.0/manual/api/reference/configuration/export
 */
public class ConfigurationExportRequestBuilder extends RequestBuilder<Map<String,Object>> {
    public enum FORMAT{json,xml}
    private FORMAT format;
    private Map<String,Object> options;
    public ConfigurationExportRequestBuilder(String auth) {
        super("configuration.export", auth);
        baseRequest.setParams(new HashMap<>());
    }

    public ConfigurationExportRequestBuilder(Long id, String auth) {
        super("configuration.export", id, auth);
        baseRequest.setParams(new HashMap<>());
    }

    public ConfigurationExportRequestBuilder setParam(String key, Object value){
        baseRequest.getParams().put(key,value);
        return this;
    }
    public ConfigurationExportRequestBuilder setParams(Map<String,Object> params){
        baseRequest.getParams().putAll(params);
        return this;
    }

    public FORMAT getFormat() {
        return format;
    }

    public ConfigurationExportRequestBuilder setFormat(FORMAT format) {
        this.format = format;
        return this;
    }

    public Map<String, Object> getOptions() {
        return options;
    }

    public ConfigurationExportRequestBuilder setOptions(Map<String, Object> options) {
        this.options = options;
        return this;
    }

    @Override
    public BaseRequest<Map<String, Object>> builder() {
        baseRequest.getParams().put("format",format.name());
        baseRequest.getParams().put("options",options);
        return baseRequest;
    }
}
